<template>
	<view class=" block" v-if="pageShow">
		<view class="" style="padding-bottom: 150rpx;">
			<view class=" flexleft mainpadding ffffff xiahuaxian">
				<image class="touxiang margin_right1" :src="dataAll.avatar" mode=""></image>
				<view class="">
					<view class="ershiba xiaohei">{{dataAll.nickName}}</view>
					<view class="smalltext xiaohui margin_top1">{{dataAll.createTime}}</view>
				</view>
			</view>
			<view class="ffffff mainpadding2">
				<view class="xiaohei sanshier fonweight" style="padding-top: 30rpx;">{{dataAll.content}}</view>
				<template v-if="dataAll.image">
					<image class="margin_top" style="width: 100%;" v-for="(item,index) in dataAll.imageArray" @click="lbtpriview(index,dataAll.imageArray)" :key="index" :src="item" mode="widthFix"></image>
				</template>
			</view>
			<!-- 评价 -->
			<view class="ffffff mainpadding margin_top2" v-if="list.length">
				<view class="ershiba xiaohei">{{$t('dt.qbpl')}}</view>
				<view class="flextop margin_top" v-for="item in list" :key="item.id" @click="focus=true;pid=item.id">
					<image class="pltx" :src="item.avatar" mode=""></image>
					<view class="xiahuaxian" style="width: 88%;">
						<view class="strongtext xiaohui">{{item.nickName}}</view>
						<view class="margin_top1">
							<text class="ershiba margin_right1">{{item.content}}</text>
							<text class="ershiba xiaohui smalltext">{{item.createTime}}</text>
						</view>
						<view class="flextop margin_top" v-for="ite in item.replyList" :key="ite.id">
							<image class="plxtx" :src="ite.avatar" mode=""></image>
							<view class="" style="width: 92%;">
								<view class="strongtext xiaohui">{{ite.nickName}}</view>
								<view class="margin_top1">
									<text class="ershiba margin_right1">{{ite.content}}</text>
									<text class="ershiba xiaohui smalltext">{{ite.createTime}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 固定底部 -->
		<view class="gudingdb ffffff mainpadding">
			<view class="shurbox mainpadding2s">
				<input type="text" :placeholder="$t('dt.yspl')" :focus="focus" @blur="focus=false;pid=''" v-model="contents" @confirm="sendmsg" confirm-type="send">
			</view>
		</view>
		
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				dataAll: {},
				pageShow: false,
				page: 1,
				limit: 12,
				list: [],
				ischudi:false,//是否触底
				contents:"",
				pid:"",
				focus:false,
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
		},
		
		onShow() {
			this.getDetail()
		},
		methods: {
			sendmsg(){
				if(this.contents==""){
					httpRequest.toast(this.$t('dt.nrbwk'))
					return false
				}
				let data = {
					noteId: this.listid,
					replyId: this.pid,
					content: this.contents,
					type:this.pid?2:1
				}
				let url = '/api/v1/note/reply/add';
				httpRequest.request(url, 'POST', data).then(res => {
					if (res.code == 200) {
						this.pid = ""
						this.contents = ""
						this.init()
					}else{
						httpRequest.toast(res.msg)
					}
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					pageNum: page || 1,
					pageSize: _this.limit,
					noteId: this.listid,
				}
				let url = '/api/v1/note/reply/list'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 200) {
						if(res.data.length==0){
							this.ischudi = true
							return false
						}else{
							this.ischudi = false
						}
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list = dataList.concat(resList);
						} else {
							this.list = []
							this.list = res.data
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let page = _this.page;
				if (_this.ischudi) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			getDetail() {
				httpRequest.request('/api/v1/note/user/detail', 'GET', {
					noteId: this.listid,
				}).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.lines {
		width: 60rpx;
		height: 2rpx;
		background-color: #2361ff;
	}
	
	.line {
		width: 80rpx;
		height: 2rpx;
	}
	.dticon {
		width: 48rpx;
		height: 48rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.shurbox {
		background: #F4F4FC;
		border-radius: 32rpx;
	}

	.dbtx {
		width: 56rpx;
		height: 56rpx;
		border-radius: 50%;
	}

	.plxtx {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
	}

	.pltx {
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
	}

	.tupian {
		width: 686rpx;
		height: 1220rpx;
	}

	.block {
		background: #F9F9F9;
		min-height: calc(100vh - 100rpx);
		height: auto;
	}

	.guaznbtn {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		width: 138rpx;
		height: 64rpx;
		background: #2361FF;
		border-radius: 32rpx;
	}
	.dhbtn {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333;
		width: 138rpx;
		height: 64rpx;
		background: #F5F5F5;
		border-radius: 32rpx;
	}
	.touxiang {
		width: 64rpx;
		height: 64rpx;
		border-radius: 50%;
	}
	.touxiangs{
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
	}
</style>